package com.bdqn.service.impl;

import com.bdqn.dao.UserDao;
import com.bdqn.service.UserService;
import entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("userService")

//bean的作用域：默认值为singleton：单例模式，整个应用种只有一个实例
//prototype：每次送spring容器中获取bean都会创建一个新的实例
//request：每次请求创建新的实例
//session：在一次会话中创建一个实例
@Scope("prototype")
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }



    @Override
    public List getUserList() {
        return userDao.getUserList();
    }

    @Override
    public void addUser(User user) {
        userDao.addUser(user);
    }


}
